﻿using EyFramework.ORM;
using EyFramework.Sys.Entity;
using System.Collections.Generic;
using System.Linq;

namespace EyFramework.Sys.Core.Dao
{
    public class SysMenuDao : BaseDaoHis<SysMenu>, ISysMenuDao
    {
        /// <summary>
        /// 根据用户ID，系统ID获取菜单列表
        /// </summary>
        /// <param name="usrId"></param>
        /// <param name="sysId"></param>
        /// <returns></returns>
        public List<SysMenu> GetUserMenusBy(string usrId, string sysId)
        {
            string sql = "SELECT M.* FROM SYS_ROLE_MENU RM,SYS_USER U,SYS_USER_ROLE R,SYS_MENU M WHERE RM.ROLE_ID=R.ROLE_ID AND U.USER_ID=R.USER_ID AND RM.MENU_ID=M.MENU_ID AND U.USER_ID=:USER_ID AND M.SYS_ID=:SYS_ID ORDER BY ORDER_NUM";
            return Db.Ado.SqlQuery<SysMenu>(sql, new { USER_ID = usrId, SYS_ID = sysId }).ToList();
        }
    }
}